<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" import="com.hpeng.sys.service.*"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%String path=request.getContextPath();
String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
	<title><s:text name="sys.app_title" /></title>
	<%@include file="../include/contentheader.jsp"%>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <link rel="stylesheet" type="text/css" href="css/dtree.css"/>
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.blockUI.js"></script> 
	<script type="text/javascript" src="js/dtree.js"></script>
	<script type="text/javascript" src="js/app.js"></script>
	
		<!-- DWR -->
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
	   	<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/categoryManager.js"></script>
<script type="text/javascript">


//根据条件查询资产信息
   function queryAssetCard(){
    	   var property=document.getElementById("condition");
   		   var condition=property.options[property.selectedIndex].value;
   		if(condition=="zczt"){
   			var propertyBeChoose=document.getElementById("acstatusValue");
   			var acstatusValue=propertyBeChoose.options[propertyBeChoose.selectedIndex].value;
   			location.href = "queryAssetCardManage.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&acstatusValue="+encodeURIComponent($('#acstatusValue').val());
   			//alert("queryAssetCardManage.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&acstatusValue="+encodeURIComponent($('#acstatusValue').val()));   
   		}else{
   			var conditionValue=document.getElementById("conditionValue").value;
     	    location.href="queryAssetCardManage.action?FN=<s:property value='FN' />&condition="+encodeURIComponent($('#condition').val())+"&conditionValue="+encodeURIComponent($('#conditionValue').val());   
   		}
    		 }
//将数据导出
   function exportTable(){ 
	   if(confirm("确定要导出所有记录吗?")){
          window.location.href="outputassetCard.action?FN=<s:property value='FN' />";
	   } 
   }
//修改数据
   function updateAssetCard(){
	   var allId = document.getElementsByName("checkbox");
	      var array = new Array(allId.length);
	      var j=0;
	      for(var i=0;i<allId.length;i++){
	         if(allId[i].checked==true){
	              array[j] = allId[i].value;
	              j++;
	         }
	      }
	      //如果没有被选中，那么不进行任何操作
	      if(j==0){
	    	   alert('请选择要进行修改的记录.');
	           return;
	           }
	      var newArray = new Array(j);
	      for(var i=0;i<j;i++){
	          newArray[i]=array[i];
	      }
	      if(j > 1){
				alert('请选择某一条具体的记录再进行此操作.');
				return false;
			}
	         document.getElementById("updatecardid").value = newArray; 
	         document.getElementById("updateform").submit();
	   }

//刷新页面
  function refresh(){
	    window.location.href="page/basic/searchAssetCardCSchange.action?FN=<s:property value='FN' />";
	  }


//条件选择
	function chose(){
		var property=document.getElementById("condition");
		var conditionValue=document.getElementById("conditionValue");
		var acstatusValue=document.getElementById("acstatusValue");
		if(property.options[property.selectedIndex].value=="zczt"){
			conditionValue.style.display="none";	
			acstatusValue.style.display="inline";
		}else{
			conditionValue.style.display="inline";	
			acstatusValue.style.display="none";
		}
	}
</script>	   	
  </head>
  
  <body>
  <div class="mainContainer">
    <div class="headerTitle">日常信息管理&nbsp;>>&nbsp;资产卡片参数管理</div>
    
       <div class="dtreeDiv" id="managerTree">
			<script type="text/javascript">
				var myTree = document.getElementById("managerTree");
				d = new dTree('d');
				var inner;
				buildTree();
				function buildTree(){
					categoryManager.findAllCategory(function(category) {
						d.add(0, -1, '广元电业局',"searchAssetCardCSchange.action?FN=<s:property value='FN' />");
						for(var i=0; i<category.length; i++){
							var size = category[i].catid.length;
							var url = "getAssetByCategory.action?FN=<s:property value='FN' />&catid="+category[i].catid;
							if(size == 3){
								d.add(category[i].catid,0,category[i].catname,url);
							}else if(size == 6){
								d.add(category[i].catid,category[i].catid.substr(0,3),category[i].catname,url);
							}else if(size == 10){
								d.add(category[i].catid,category[i].catid.substr(0,6),category[i].catname,url);
							}
						}
						inner = d.toString();
						showBuildTree();
					});
				}
				function showBuildTree() {
					myTree.innerHTML = inner;
				}
				
			</script>
		</div>
		
     	<div class="dataDivLeftHasTree">
     	
     	<table class="gridTable" border="0" cellspacing="0" cellpadding="0">
			<tr class="operatorAction">
				<td><s:if test="accessRight.indexOf('V')!=-1">
					 <input type="button" style="margin-left:2px;" value="刷新" onclick="refresh();"/>
					</s:if>
					<s:if test="accessRight.indexOf('E')!=-1">
					<input type="button" style="margin-left:2px;" value="修改" onclick="updateAssetCard();" />
					</s:if>
				    <s:if test="accessRight.indexOf('O')!=-1"> 
					<input type="button" style="margin-left:2px;" value="导出" onclick="exportTable();" />
				    </s:if>
				    <s:if test="accessRight.indexOf('V')!=-1">
					查询条件：根据&nbsp;&nbsp;<select style="width: 94px;"  id="condition" onblur="chose();"> 
		  					<option selected="selected" value="zclb">资产类别</option>
		  					<option value="zczt">资产状态</option>
		  					<option value="sbbm">申报部门</option>
		  				</select>
		  				<input style="margin-left:10px;" type="text" id="conditionValue" />
		  				<select style="display:none;width: 150px" class="qryTxt" id="acstatusValue">
	  						<option value="110" selected="selected">申报-经办已录入</option>
							<option value="111">申报-经办已上报</option>
							<option value="120">申报-部门领导已审核</option>
							<option value="121">申报-部门领导已上报</option>
							<option value="131">申报-局领导已审核</option>
							<option value="400">在用-物资正在使用</option>
							<option value="340">出库-物资部经办已确认</option>
							<option value="341">出库-接收部门已确认</option>
							<option value="342">出库-接收部物资待分配</option>
							<option value="501">内调-部门经办已申请</option>
							<option value="502">内调-部门经办已上报</option>
							<option value="503">内调-部门领导已审核</option>
							<option value="750">残值-部门经办已申请</option>
							<option value="751">残值-部门经办已上报</option>
							<option value="752">残值-部门领导已审核</option>
							<option value="753">残值-部门领导已上报</option>
							<option value="754">残值-局领导已审核</option>
							<option value="860">外调-原部门经办已申请</option>
							<option value="861">外调-原部门经办已上报</option>
							<option value="862">外调-原部门领导已审核</option>
							<option value="863">外调-原部门经办已黄钻叫</option>
							<option value="864">外调-新部门领导已审核</option>
							<option value="865">外调-新部门领导已下传</option>
							<option value="601">报废-部门经办已录入</option>
							<option value="602">报废-部门经办已上报</option>
							<option value="603">报废-部门领导已审核</option>
							<option value="604">报废-部门领导已传递</option>
							<option value="605">报废-物资部已确认</option>
							<option value="201">入库-物资部经办已确认</option>
							<option value="202">入库-物资部经办已上报</option>
							<option value="203">入库-物资部领导已审核</option>
							<option value="901">盘点-盘盈数据已录入</option>
							<option value="902">盘点-盘盈入库已申报</option>
							<option value="903">盘点-盘亏已申报</option>
							<option value="904">盘点-盘亏财务部已审核</option>
							<option value="905">盘点-盘亏财务部已上报</option>
							<option value="906">盘点-盘亏确认</option>

							
	  					</select>
		       	        <input type="button" style="margin-left:1px;" value="查询" onclick="queryAssetCard()"/>
			       </s:if>
				</td>
			</tr><%-- 功能性操作行 --%>
			<tr>
				<td class="gridData">
				
					<table class="dataTable" border="0" cellpadding="0" cellspacing="1">
					  	<tr class="dataHeader">
					  			<!-- 数据表头 -->
						  <td width="3%"><input id="checkAll" type="checkbox" name="check" value="checkbox" /></td> 
					      <td width="8%">资产名称</td>	
						  <td width="8%">资产简称</td>
						  <td width="12%">资产状态</td>
						  <td width="10%">资金来源</td>
						  <td width="6%">申请部门</td>
						  <td width="6%">生产日期</td>
						  <td width="6%">使用期限</td>
						  <td width="9%">预计停用日期</td>
						  <td width="9%">实际停用日期</td>
						  <td width="3%">单价</td>
						  <td width="6%">计量单位</td>
						  <td width="6%">资产规格</td>
						  <td width="8%">生产厂家</td>
						</tr>
								          
								<!-- 数据 -->
						<s:iterator var="ac" value="pagination.dataList">    
						<tr class="dataRow" id="<s:property value='#ac.acid'/>" ondblclick="updateAssetCard('<s:property value="#ac.acid" />')">
						  <td><input name="checkbox" type="checkbox" value="<s:property value='#ac.acid'/>" id="selectItem" /></td>
						  <td><s:property value="#ac.acname" /></td>
						  <td><s:property value="#ac.acanothername"/></td>
						  <td> 
						     <s:iterator value="ls">
						       <s:if test="value==#ac.acstatus">
						             <s:property value="desc"/>  
						       </s:if>
						     </s:iterator>
						     
						  </td>
						 
						  <td><s:property value="#ac.assetcomefrom"/></td>
						  <td><s:property value="#ac.reportdepartment"/></td>
						  <td>
						    <fmt:formatDate value="${ac.producedate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.lifetime"/></td>
						  <td>
						     <fmt:formatDate value="${ac.planstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td>
						     <fmt:formatDate value="${ac.actualstopdate}" pattern="yyyy/MM/dd"/>
						  </td>
						  <td><s:property value="#ac.reportprice"/></td>
						  <td><s:property value="#ac.category.catunit"/></td>
						  <td><s:property value="#ac.category.catnorms"/></td>
						  <td><s:property value="#ac.producer"/></td>
						  
						</tr>
						</s:iterator><%-- 数据循环结束 --%>
     				</table><%-- 数据表格结束 --%>
     			</td>	<%-- 数据 --%>
     		</tr>	<%-- 数据表格 --%>
			<tr class="dataPager">
				<td>
					<s:property value="pageLink" escapeHtml="false" />
				</td>
			</tr>
     	</table>
    </div>
</div>  		

<!-- 提交修改根据Id的资产信息 -->
   <form action="getCard.action" method="post" id="updateform">
    	<input type="hidden" id="updatecardid" name="acid"/>
    	<input type="hidden" id="FN" name="FN" value="<s:property value='FN' />" />
   </form>
  </body>
</html>
